﻿using System.Linq;
using BankCreditPortfolio.DAL.Entities;

namespace BankCreditPortfolio.DAL.Services
{
    public class DepositService : DataService<Deposit>
    {
        public Deposit GetBankDeposit(string currency)
        {
            var filteredQuery = this.CreateQuery().Where(x => x.DepositType.Title == "Bank" && 
                                                         x.Currency.Title == currency);
            return filteredQuery.Count() > 0 ? filteredQuery.Single() : null;
        }

        public IQueryable<Deposit> GetBankDeposits()
        {
            var filteredQuery = this.CreateQuery().Where(x => x.DepositType.Title == "Bank").OrderBy(x => x.Amount);
            return filteredQuery.Count() > 0 ? filteredQuery : null;
        }

        public IQueryable<Deposit> GetClientDeposits()
        {
            var filteredQuery = this.CreateQuery().Where(x => x.DepositType.Title == "Client").OrderBy(x => x.Amount);
            return filteredQuery.Count() > 0 ? filteredQuery : null;
        }
    }
}